﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeAgeDetailLookUpList.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.FTradeAgeDetailLookUpList" %>

<form id="pagerForm" method="post" action="FTradeModel/FTradeAgeDetailLookUpList.aspx">
<input type="hidden" name="JingXiaoShang" value="<%=JingXiaoShang %>" />
<input type="hidden" name="JiHao" value="<%=JiHao %>" />
<input type="hidden" name="orderField" value="<%=orderField %>" />
<input type="hidden" name="orderDirection" value="<%=orderDirection %>" />
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="20" />
</form>
<form id="form1" runat="server" method="post" action="FTradeModel/FTradeAgeDetailLookUpList.aspx" onsubmit="return dialogSearch(this);">
<div class="pageHeader">
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>
                    <input type="hidden" name="JingXiaoShang" value="<%=JingXiaoShang %>" />
                    机号： <input name="JiHao" type="text" value="<%=JiHao %>"  />
                </td>
                <td>
                     <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div>
                            </li>
                        </ul>
                    </div>
                </td>
                <td width="330px">&nbsp;</td>
                <td width="100px">已选冲帐金额：</td>
                <td width="100px">
                <input id="FTradeAgeDetailLookUpListShowTotalMoney" readonly value="0" />
                可用:<span style="color:red;" id="FTradeAgeDetailLookUpListShowTotalMoneyCanUse">0.0</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="pageContent ">
    <asp:repeater id="rpMenu" runat="server">
        <HeaderTemplate>
        <table class="list FtradeAgeDetailLookUpListTable" width="100%" layouth="60" targetType="dialog">
        <thead>
            <tr  >                
                <th width="100">合同号</th>
                <th width="80" <%=GetDataListOrder("JiHao") %>>机号</th>
                <th width="100">终端状态</th>
                <th width="80" <%=GetDataListOrder("ShowTitle") %>>款项名称</th>                
                <th width="80" <%=GetDataListOrder("JinE") %>>金额</th> 
                <th width="80" <%=GetDataListOrder("DaoQiRi") %>>到期日</th> 
                <th width="80">已付</th> 
                <th width="60">本次冲帐</th> 

                <th width="80">融资首付款</th> 

                <th width="70">操作</th>             
            </tr>
        </thead> 
        <tbody>
        </HeaderTemplate>
        <ItemTemplate>
            <tr id="FtradeAgeDetailLookUpListTableFTradeAgeId<%# Eval("FTradeAgeId") %>" >
                <td><%# Eval("HeTongHao")%></td>
				<td><%# Eval("JiHao")%></td>
                <td><%# Eval("ZDXiaoShouState")%></td>
				<td><%# Eval("ShowTitle")%></td>
				<td><%# FormatDecimalToStrings(Eval("JinE"),"N")%></td>
                <td><%# Convert.ToDateTime( Eval("DaoQiRi")).ToString("yyyy-MM-dd")%></td>
                <td><%# FormatDecimalToStrings(Eval("YiChongJinE"),"N")%></td>
                <td>
                    <input class="BalanceMoney inputFloat"  id="BalanceMoney<%# Eval("FTradeAgeId")%>" maxmoney="<%# Convert.ToDecimal(Eval("JinE"))-Convert.ToDecimal(Eval("YiChongJinE")) %>" value="<%# Convert.ToDecimal(Eval("JinE"))-Convert.ToDecimal(Eval("YiChongJinE")) %>" />
                </td>
                <td>
                    <input type="hidden" id="FXLPay_<%# Eval("FTradeAgeId")%>" value="0" />
                    <a class="btnSelectFXLPay" href="javascript:onSelectFXFinanceLease('<%# Eval("JiHao")%>','FXLPayShow_<%# Eval("FTradeAgeId")%>','FXLPay_<%# Eval("FTradeAgeId")%>','BalanceMoney<%# Eval("FTradeAgeId")%>')" >选择融资合同</a><br/>
                    <span id="FXLPayShow_<%# Eval("FTradeAgeId")%>"></span>
                </td>
			    <td>
					<a class="btnSelect" title="新增" href="javascript:onAgetDetailSelectAdd('#BalanceMoney<%# Eval("FTradeAgeId")%>','#FXLPay_<%# Eval("FTradeAgeId")%>','#FXLPayShow_<%# Eval("FTradeAgeId")%>',{FTradeAgeId:'<%# Eval("FTradeAgeId") %>', JiHao:'<%# Eval("JiHao")%>',ShowTitle:'<%# Eval("ShowTitle") %>',JinE:'<%# Eval("JinE")  %>',DaoQiRi:'<%# Eval("DaoQiRi") %>',YiChongJinE:'<%# Eval("YiChongJinE") %>',CreateDate:'<%# System.DateTime.Now.ToString("yyyy-MM-dd") %>'})" title="查找带回">选择</a>
				    <a  class="btnDel" title="删除" href="javascript:void(0);" FTradeAgeId="<%#  Eval("FTradeAgeId") %>" style="dispaly:none;">删除</a>
                </td>
			</tr>
        </ItemTemplate>
        <FooterTemplate>
            </tbody>
         </table>
        </FooterTemplate>
    </asp:repeater>
    <script type="text/javascript">
        $(document).ready(function () {
            $("table.FtradeAgeDetailLookUpListTable").find("input.BalanceMoney").blur(function () {
                var $maxmoney = parseFloat($(this).attr("maxmoney"));
                var $inputmoney = parseFloat($(this).val());
//                if ($inputmoney <= 0) {
//                    alert("你所输入的冲帐金额小于0,请重输");
//                    $(this).val("0");
//                    return false;
//                }
                if ($inputmoney > $maxmoney) {
                    alert("你所输入的冲帐金额大于可用金额[" + $maxmoney + "],请重输");
                    $(this).val($maxmoney)
                    return false;
                }
            }).end().find("a.btnDel").click(function () {
                var $FTradeAgeId = $(this).attr("FTradeAgeId");
                onAgetDetailSelectAddDelete($("#FTradeBalanceAdd_AddBalanceList_Row" + $FTradeAgeId).find("a"));
                var $row = $(this).closest("tr");
                //$row.find("#BalanceMoney" + $FTradeAgeId).val(0);
                $row.css("color", "#000").find("input").removeAttr("readonly");
                $row.find("#FXLPay_" + $FTradeAgeId).val("0");
                $row.find("#FXLPayShow_" + $FTradeAgeId).html("");

                $(this).hide();
                $(this).closest("td").find("a.btnSelect").show();
                $row.find("a.btnSelectFXLPay").show();
                proccessTotalMoney();
            }).hide();

            function proccessTotalMoney() {
                $("#FTradeAgeDetailLookUpListShowTotalMoney").val(0);
                //处理已添加
                var $AddBalanceListTbody = $("#FTradeBalanceAdd_AddBalanceList").find("tbody");
                //处理已选择
                $AddBalanceListTbody.find("tr").each(function () {
                    var $FTradeAgeId = $(this).find("input[name='FTradeAgeId']").val();
                    var $BalanceMoney = $(this).find("input[name='BalanceMoney']").val();
                    var $totalmoney = $("#FTradeAgeDetailLookUpListShowTotalMoney").val();
                    var $FXLPay = $(this).find("input[name='FnncLsId']").val();
                    var $FXLPayShow = $(this).find(".FXLPayShow").html()


                    var rowExist = $("table.FtradeAgeDetailLookUpListTable").find("#FtradeAgeDetailLookUpListTableFTradeAgeId" + $FTradeAgeId).attr("id");
                    if (rowExist != undefined) {
                        var $row = $("table.FtradeAgeDetailLookUpListTable").find("#FtradeAgeDetailLookUpListTableFTradeAgeId" + $FTradeAgeId);
                        $row.find("#BalanceMoney" + $FTradeAgeId).val($BalanceMoney);
                        $row.find("#FXLPay_" + $FTradeAgeId).val($FXLPay);
                        $row.find("#FXLPayShow_" + $FTradeAgeId).html($FXLPayShow);

                        $row.css("color", "red").find("input").attr("readonly", true);
                        $row.find("a.btnSelectFXLPay").hide();
                        $row.find("a.btnSelect").hide();
                        $row.find("a.btnDel").show();
                        //return;
                    }
                    $("#FTradeAgeDetailLookUpListShowTotalMoney").val(parseFloat($totalmoney) + parseFloat($BalanceMoney));

                })
                $("#FTradeAgeDetailLookUpListShowTotalMoneyCanUse").html(parseFloat($("#FTradeBalanceAdd_ShengYuJinE").val()) - parseFloat($("#FTradeAgeDetailLookUpListShowTotalMoney").val()));
            }

            proccessTotalMoney();

        })

        function onSelectFXFinanceLease($JH, $showId, $hiddenId, $BalanceMoneyid)
        {
            var rel = "FTradeAgentSlectFXFinance";
            var url = "FTradeModel/FTradeAgentSlectFXFinance.aspx?JingXiaoShang=" + encodeURI("<%=JingXiaoShang %>") + "&JiHao=" + $JH + "&showid=" + $showId + "&hiddenid=" + $hiddenId + "&BalanceMoneyid=" + $BalanceMoneyid;
            var title = "请选择<%=JingXiaoShang %>的未付清的融资首付合同";
            var options = { width: 950, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            top.$.pdialog.open(url, rel, title, options);
        }

    </script>
     <div class="panelBar">
        <div class="pages">
            <span>显示</span>
            <select class="combox" name="numPerPage" onchange="dialogPageBreak({numPerPage:this.value})">
               <%=SetnumPerPage() %>
            </select>
            <span>条，共<%=TotalCount%>条</span>
        </div>
        <div class="pagination" targettype="dialog" totalcount="<%=TotalCount%>" numperpage="<%=numPerPage %>"
            pagenumshown="10" currentpage="<%=pageNum %>">
        </div>
    </div>
</div>
</form>
